home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '88 / Other stuff / CLIP stuff / CLIP sources / mkmxa.c next >
Encoding:
C/C++ Source or Header  |  1986-05-07  |  3.3 KB  |  102 lines  |  [TEXT/FstE]

  1. /*  Copyright (c)   Mar, 1986   UMMC.  All rights reserved
  2.  
  3. Filename:       mkmxa.c
  4.  
  5. Abstract:       This module contains the code to construct the matrices used to transform between
  6.                 The AP image coordinates and the patient/table coordinates
  7.  
  8. Environment:    UM/CLIP
  9.  
  10. Revision History:
  11.     Rev #      Date    Auth     Reason
  12.     -----   ---------  -----    ----------------------------------
  13.      0.0    17-mar-86   js      original implementation
  14.      0.1    28-apr-86   js      converted to double precision
  15.     
  16. -----------------------------------------------------------------------------------------
  17. NAME:
  18.  
  19.     mkmxa - make coordinate transform matrices (AP)
  20.  
  21. SYNOPSIS:
  22.  
  23.     ERRCODE mkmxa (alpha, beta, a2p, p2a)
  24.         
  25.         INT         alpha;          angle alpha for the AP C-arm
  26.         INT         beta;           angle beta for the AP C-arm
  27.         DOUBLE      a2p[9];         array for 'AP to patient' transform matrix
  28.         DOUBLE      p2a[9];         array for 'patient to AP' transform matrix
  29.  
  30. MODIFIED ARGUMENTS:
  31.  
  32.     a2p and p2a will contain the transform matrices corresponding to angles alpha and beta
  33.  
  34. FUNCTION:
  35.  
  36.     Matrix methods are used in order to implement transformations between the coordinate
  37.     systems subtended by the AP image plane and the patient.  It is the function of this
  38.     routine to construct the  required matrices based on the angulation of the C-arm.  The
  39.     form of the matrices is the following (a = alpha & b = beta):
  40.         
  41.                 p2a:
  42.                  
  43.                     -cos b  -sin a sin b    cos a sin b
  44.                     0       cos a           sin a
  45.                     sin b   -sin a cos b    cos a cos b
  46.                     
  47.                 a2p:
  48.                 
  49.                     -cos b          0       sin b
  50.                     -sin a sin b    cos a   -sin a cos b
  51.                     cos a sin b     sin a   cos a cos b
  52.  
  53. PROGRAMMING NOTES:
  54.  
  55.     The elements of the matrices will be stored as sequential rows in the array.
  56.         
  57. EXAMPLES:
  58.  
  59. =============================================================================*/
  60.  
  61. #include    "clipinclude.h"
  62.  
  63.     ERRCODE mkmxa (alpha, beta, a2p, p2a)
  64.         
  65.     INT         alpha;          /* angle alpha for the AP C-arm */
  66.     INT         beta;           /* angle beta for the AP C-arm */
  67.     DOUBLE      a2p[9];         /* array for 'AP to patient' transform matrix */
  68.     DOUBLE      p2a[9];         /* array for 'patient to AP' transform matrix */
  69.  
  70.     {
  71.     
  72.     DOUBLE      sina, cosa;     /* sine and cosine of alpha */
  73.     DOUBLE      sinb, cosb;     /* sine and cosine of beta */
  74.     ERRCODE     erret = OK;     /* error code */
  75.     
  76.     DOUBLE      sin ();         /* sine function */
  77.     DOUBLE      cos ();         /* cosine function */
  78.     
  79. /* get copies of sine's and cosine's */
  80.  
  81.     sina = sin((DOUBLE)alpha * Pi / 180);
  82.     cosa = cos((DOUBLE)alpha * Pi / 180);
  83.     sinb = sin((DOUBLE)beta * Pi / 180);
  84.     cosb = cos((DOUBLE)beta * Pi / 180);
  85.     
  86. /* construct matrices */
  87.  
  88.     p2a[0] = a2p[0] = -cosb;
  89.     p2a[1] = a2p[3] = -sina * sinb;
  90.     p2a[2] = a2p[6] = cosa * sinb;
  91.     p2a[3] = a2p[1] = 0;
  92.     p2a[4] = a2p[4] = cosa;
  93.     p2a[5] = a2p[7] = sina;
  94.     p2a[6] = a2p[2] = sinb;
  95.     p2a[7] = a2p[5] = -sina * cosb;
  96.     p2a[8] = a2p[8] = cosa * cosb;
  97.     
  98. /* all done */
  99.  
  100.     return (erret);
  101.     
  102.     }